<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script type="text/javascript" src="js/jquery-1.12.2.min.js"></script>
</head>
<body>
<form onsubmit="return false;">

    旧密码:<input type="password" name="oldPassword"><br>
    新密码:<input type="password" name="newPassword"><br>
    <input type="submit" name="修改">
</form>
</body>
<script>
    $("form").submit(function () {
        $.ajax({
            type:"post",
            url:"updatePassword.do",
            data:$("form").serialize(),
            dataType:"json",
            success:function (data) {
                if (data.code == 1) {
                    alert(data.info)
                } else {
                    alert(data.info)
                }
            }
        })
    })
</script>
</html>